<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        // 构造函数
        // function Student (name, age, sex) {
        //     this.name = name;
        //     this.age = age
        //     this.sex = sex
        //     this.sayHi = function() {
        //         console.log("大家好, 我是", this.name)
        //     }
        // }

        // var s1 = new Student('lilei', 19 , "男")
        // var s2 = new Student('hmm', 20, '女')

        // s1.sayHi()
        // s2.sayHi()

        // console.log(s1.sayHi === s2.sayHi)

///=====================


        // function Student (name, age, sex) {
        //     this.name = name;
        //     this.age = age
        //     this.sex = sex
        //     this.sayHi = sayHi
        // }

        // var sayHi = function() {
        //     console.log("大家好, 我是", this.name)
        // }

        // var s1 = new Student('lilei', 19 , "男")
        // var s2 = new Student('hmm', 20, '女')

        // s1.sayHi()
        // s2.sayHi()

        // console.log(s1.sayHi === s2.sayHi)

///=====================


        function Student (name, age, sex) {
            this.name = name;
            this.age = age
            this.sex = sex
        }

        Student.prototype.sayHi = function() {
            console.log("大家好, 我是", this.name)
        }

        var s1 = new Student('lilei', 19 , "男")
        var s2 = new Student('hmm', 20, '女')

        s1.sayHi()
        s2.sayHi()

        console.log(s1.sayHi === s2.sayHi)

        console.dir(s1)
    </script>
</body>
</html>